<?php
/**
 * Interface zum Db_Connector
 *
 * @author		Joachim Ruf
 * @copyright	Copyright (c) 2003-2010 Loresoft Software (http://www.loresoft.de)
 * @license		http://yapary.loresoft.de/lizenzbedingungen     New BSD License
 *
 * */


class Yapary_Db_Sql_Database Implements Yapary_Db_IDatabase
{
    private $exception    = NULL;
	private $connection   = NULL;


    function __construct ($_connection) {
        $this->exception = new Yapary_Exception_Exception();
    	$this->connection = $_connection;
    }


    /**
     * Gibt eine Instanz der Table-Klasse aus
     * @return Yapary_Db_ITable
     * */
    public function table ($_tableName) {
        return new Yapary_Db_Sql_Table($this->connection, $_tableName);
    }


    /**
     * Liefert alle Tabellennamen aus
     * @return Array|NULL
     * */
    public function getList () {
        $arrResult = array();

		$resId = @mysql_query('SHOW TABLE STATUS', $this->connection);
		if (gettype($resId) !== 'resource') {
            $this->exception->add('Error while getting table status: '.mysql_error());
            return NULL;
		}

		while ($result = @mysql_fetch_array($resId)) {
			$arrResult[] = $result["Name"];
		}

	    return $arrResult;
    }




}


?>